package zozopo.background.operator;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.background.operator.operations.LimitedOS;
import zozopo.background.operator.operations.LimitedTB;
import zozopo.background.operator.operations.OperatorOS;
import zozopo.background.operator.operations.OperatorTB;
import zozopo.background.operator.operations.OperatorlimitedOS;
import zozopo.background.operator.operations.OperatorlimitedTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class PreAddOperatorlimitedAction extends ActionSupport implements Action,SessionAware{
	
	
	//传入参数
	private String email = "";
	
	private Map<Object, Object> session;
	
	//传出参数
	private OperatorTB operator;

	private List<OperatorlimitedTB> operatorlimitedList;
	private List<LimitedTB> limitedList;
	
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	
	public String execute(){
			
			
			OperatorOS operatorOS = new OperatorOS();
			OperatorlimitedOS userlimitedOS = new OperatorlimitedOS(operatorOS.getConn());
			LimitedOS limitedOS = new LimitedOS(operatorOS.getConn());
			
			operatorlimitedList = userlimitedOS.selectByUserEmail(email);
			limitedList = limitedOS.selectByUserLimitelist(operatorlimitedList);
			operator = operatorOS.getInfoByEmail(email);
			operatorOS.releaseConnection();

			return SUCCESS;
			
	}

	public void validate() {
		//权限处理
	
		OperatorTB operator = (OperatorTB)session.get("operatorInfo"); 
	
		if(operator == null){
			addFieldError("errormessage",getText("operator.timeoutornotlogin"));
			return ; 
		} 
		if(!OperatorOS.operatorFlagLeve(operator, 17, 1)){
			
			addFieldError("errormessage","权限不足");
			return ; 
		}//*/
		
	}

	public List<LimitedTB> getLimitedList() {
		return limitedList;
	}

	public void setLimitedList(List<LimitedTB> limitedList) {
		this.limitedList = limitedList;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public OperatorTB getOperator() {
		return operator;
	}

	public void setOperator(OperatorTB operator) {
		this.operator = operator;
	}

	public List<OperatorlimitedTB> getOperatorlimitedList() {
		return operatorlimitedList;
	}

	public void setOperatorlimitedList(List<OperatorlimitedTB> operatorlimitedList) {
		this.operatorlimitedList = operatorlimitedList;
	}



}
